define(function(require, exports, module) {
	var $=require("zepto");
	var Loader=require("widgets/Loader");
	var Mobilebone=require('mobilebone');
	var App=require("app");
	exports.init = function(page) {
		var loader=new Loader();
		loader.show();
		App.addCssFile("css/ProductCategary.css","ProductCategary_css",function(){
			var tpl=buildSearch()+buildcategaryList();
			page.querySelector(".content").querySelector("div").innerHTML=tpl;
			addListener(page);
		});
		setTimeout(function(){
			loader.hide();
		},1000);
	};
	function buildSearch(){
		var tpl='<div class="new-cate-srch">';
				tpl+='<div class="new-srch-box">';
					tpl+='<input name="keyword" id="newkeyword" type="text" required="" class="new-srch-input" value="JDPhone" style="color:#999999;">';
					tpl+='<a target="_self" class="new-s-close"></a>';
					tpl+='<a target="_self" class="new-s-srch">';
						tpl+='<span></span>';
					tpl+='</a>';
				tpl+='</div>';
				tpl+='<div class="new-srch-lst" id="shelper" style="display: none;"></div>';
			tpl+='</div>';
		return tpl;
	};
	function buildcategaryList(){
		var tpl='<div class="new-ct">';
				tpl+='<div class="new-category">';
					tpl+='<ul class="new-category-lst">';
						tpl+='<li class="new-category-li">';
						  tpl+='<a href="javascript:void(0)" id="1315" class="new-category-a">';
							tpl+='<span class="icon"></span>';
							tpl+='服饰内衣';
						  tpl+='</a>';
						  tpl+='<ul class="new-category2-lst" id="category1315" style="display: none;">';
							tpl+='<li class="new-category2-li">';
							  tpl+='<a class="new-category2-a">';
								tpl+='<span class="new-bar">';
								tpl+='</span>';
								tpl+='男装';
							  tpl+='</a>';
							  tpl+='<a class="new-category2-a">';
								tpl+='<span class="new-bar"></span>';
								tpl+='女装';
							  tpl+='</a>';
							   tpl+='<a class="new-category2-a">';
								tpl+='<span class="new-bar"></span>';
								tpl+='女装';
							  tpl+='</a>';
							tpl+='</li>';
							tpl+='</ul>';
						tpl+='</li>';
					tpl+='</ul>';
				tpl+='</div>';
		return tpl;
	}
	function addListener(page){
		var categoryLstArr=$(page).find(".new-category-li .new-category-a");
		for(var i=0;i<categoryLstArr.length;i++){
			var categoryLst=categoryLstArr[i];
			$(categoryLst).on("click",function(){
				var next=$(categoryLst).next()[0];
				if(next.style.display==""){
					
					$(this).removeClass("new-on");
					next.style.display="none";
				}else{
					$(this).addClass("new-on");
					next.style.display="";
				}
			});
		}
	}
});